<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/jq.mselect.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.mselect.js?"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.multiselect.js"></script>
<script type="text/javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	var product_categories_data = <?=$product_categories?>;
	$(document).mselect(product_categories_data, 'product_categories_id', 'product_categories_id', "<?=(isset($_GET['product_categories_id']))?$_GET['product_categories_id']:0?>");
	$("#warehouse_multiselect").multiselect({height: 260, minWidth: 160});
	$("#form").submit(function(){
		if (! $("#product_categories_id").val() && ! $("#sku").val())
		{
			alert("SKU和分类至少填写一项!");
			return false;
		}
	});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get" id="form">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>&nbsp;</th>
	<th>出库日期</th>
	<td>
		<input name="begin_shipped_time" value="<?=isset($_GET['begin_shipped_time']) ? $_GET['begin_shipped_time'] : date('Y-m-01', CURRENT_TIMESTAMP)?>" class="datepicker" /> to
		<input name="end_shipped_time" value="<?=isset($_GET['end_shipped_time']) ? $_GET['end_shipped_time'] : date('Y-m-d', CURRENT_TIMESTAMP)?>" class="datepicker" />
	</td>
</tr>
<tr>
	<th>&nbsp;</th>
	<th>仓库</th>
	<td>
		<select name="warehouse_id[]" multiple="multiple" id="warehouse_multiselect">
		<?foreach ($warehouse as $w):?>
		<option value="<?=$w['id']?>" <?if (isset($_GET['warehouse_id']) && is_array($_GET['warehouse_id']) && in_array($w['id'], $_GET['warehouse_id']))echo "selected='selected'"?>><?=$w['name']?></option>
		<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>&nbsp;</th>
	<th>SKU</th>
	<td>
		<input type="text" name="sku" id="sku" size="54" value="<?=isset($_GET['sku']) ? $_GET['sku'] : ''?>" /> 多个sku用英文逗号隔开(例：000001,000002 )
	</td>
</tr>
<tr>
	<th>&nbsp;</th>
	<th>分类</th>
	<td><input type="hidden" name="product_categories_id" id="product_categories_id" /></td>
</tr>
<tr>
	<td></td>
	<td><input type="hidden" name="is_search" value="1" /></td>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>
<?if (isset($_GET['is_search']) && $_GET['is_search'] == 1 && ! empty($report)):?>
<table class="list_table" width="50%">
<tr>
<th>国家</th>
<th>数量</th>
</tr>
<?$total_quantity = 0;?>
<?foreach ($report as $r):?>
<?$total_quantity += $r['quantity']; ?>
	<tr>
		<td><?=$r['country']?></td>
		<td><?=$r['quantity']?></td>
	</tr>
<?endforeach;?>
<tr>
	<td>总计</td>
	<td><?=$total_quantity?></td>
</tr>
</table>
<?endif;?>
<?php $this->_endblock();?>
